package dp.maxsum;

public class leetcode53最大子序和 {
    public int maxSubArray(int[] nums) {
        int length = nums.length;
        int[] dp = new int[length];
        dp[0] = nums[0];
        int max = nums[0];
        for (int i = 1 ; i < length; i++) {
            for (int j = 0; j < i; j++) {
                dp[i] = Integer.max(nums[i], dp[j] + nums[i]);
            }
            max = Integer.max(max, dp[i]);
        }
        return max;
    }
}
